package com.example.qxfw.nyqx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.qx.SpecialSrvStation;
import com.example.qxfw.common.entity.qx.soilHumidity;
import com.example.qxfw.common.entity.zy.AgriProduct;
import com.example.qxfw.nyqx.service.AgriProductService;
import com.example.qxfw.nyqx.service.DroughtService;
import com.example.qxfw.nyqx.service.SoilHumidityService;
import com.example.qxfw.nyqx.service.TrsqService;
import com.example.qxfw.qxzs.service.SpecialSrvStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(tags = "农业气象-土壤熵情")
@RestController
@CrossOrigin
@RequestMapping("/trsq")
public class TrsqController {

    @Autowired
    private AgriProductService agriProductService;

    @Autowired
    private SoilHumidityService soilHumidityService;

    @Autowired
    private DroughtService droughtService;

    @Autowired
    private SpecialSrvStationService specialSrvStationService;

    @Autowired
    private TrsqService trsqService;

    @Value("${city}")
    private String city;

    @ApiOperation("查询农业产品")
    @GetMapping("/getAgriProduct")
    public SysResult getAgriProduct(String time1,String time2,String type){
        List<AgriProduct> list = agriProductService.listByParam1(time1, time2, type);
        return SysResult.success(list);
    }

    @ApiOperation("查询土壤湿度监测墒情站Id")
    @GetMapping("/getSoilHumidityStationId")
    public SysResult getSoilHumidityStationId(){
        List<String> stationId = soilHumidityService.getStationId();
        return SysResult.success(stationId);
    }

    @ApiOperation("查询干旱监测地面站Id")
    @GetMapping("/getDroughtStationId")
    public SysResult getDroughtStationId(){
        List<String> stationId = droughtService.getStationId();
        return SysResult.success(stationId);
    }

    @ApiOperation("查询土壤湿度")
    @GetMapping("/getSoilHumidity")
    public SysResult getSoilHumidity(String stationId,String time1,String time2,String level){
        List<soilHumidity> list = soilHumidityService.getList(stationId, time1, time2, level);
        return SysResult.success(list);
    }

    @ApiOperation("获取特殊服务站点信息")
    @GetMapping("/getSpecialSrvStation")
    public SysResult getSpecialSrvStation(String stationId,String flag,String city){
        List<SpecialSrvStation> list = specialSrvStationService.getList5(stationId, flag, city);
        return SysResult.success(list);
    }

    @ApiOperation("获取特殊服务站点信息")
    @GetMapping("/getStation")
    public SysResult getStation(String flag){
        List<SpecialSrvStation> specialSrvStation = trsqService.getSpecialSrvStation(flag);
        if (specialSrvStation==null){
            return SysResult.fail("不存在对应监测站或服务站");
        }
        return SysResult.success(specialSrvStation);
    }


}
